<template>
  <view class="my-success-page">
    <!-- 头部导航 -->
    <myHeader title="成功案例" />

    <view class="success-body-wrap">
      <!-- 内容区域，根据标签显示对应数据 -->
      <view class="content">
        <!-- 悬赏中 -->
        <view class="order-list" v-if="bountyList.length > 0">
          <successCaseItem
            v-for="(item, index) in bountyList"
            :key="index"
            :caseData="item"
            @onDetailClick="goDetail"
          ></successCaseItem>
        </view>
        <view class="empty-tip" v-else>
          <image
            class="empty-img"
            src="https://www.rebirthealth.com/static/images/empty-order.png"
          ></image>
          <view class="tip-text">暂无数据</view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import myHeader from "@/component/header";
import successCaseItem from "@/component/successCaseItem";
import { getSuccessList } from "@/api/index";
export default {
  components: {
    myHeader,
    successCaseItem,
  },
  data() {
    return {
      bountyList: [],
      page: {
        pageNo: 1,
        pageSize: 4,
        total: 0,
      },
    };
  },
  onShow() {
    this.page.pageNo = 1;
    this.getList();
  },
  methods: {
    async getList() {
      let res = await getSuccessList({
        pageNo: this.page.pageNo,
        pageSize: this.page.pageSize,
        orderBy: "seq",
        status: 0,
      });
      this.bountyList = res.list;
      this.page.total = res.total;
    },
    // 返回上一级页面
    goBack() {
      uni.navigateBack({
        delta: 1,
      });
    },
    goDetail(data) {
      uni.navigateTo({
        url: `/pages/success/successDetail?caseId=${data.caseId}`,
      });
    },
    onReachBottom() {
      if (this.page.total <= this.bountyList.length) {
        return;
      }
      this.page.pageSize += 4;
      this.getList();
    },
  },
};
</script>

<style lang="less" scoped>
.my-success-page {
  background-color: rgba(19, 30, 50, 1);
  min-height: 100vh;
  color: #fff;
  .success-body-wrap {
    padding: 18rpx 32rpx;
    box-sizing: border-box;
  }
  // 标签栏样式
  .tab-bar {
    display: flex;
    background: #f5f7fa;
    border-radius: 16rpx;
    padding: 16rpx 24rpx;
    justify-content: space-between;
    margin-bottom: 30rpx;
    .tab-item {
      width: 192rpx;
      height: 76rpx;
      line-height: 76rpx;
      text-align: center;
      border: 1px solid rgba(51, 158, 255, 1);
      border-radius: 4rpx;
      color: rgba(51, 158, 255, 1);
      font-size: 32rpx;
      &.active {
        background-color: rgba(4, 95, 178, 1);
        border-color: rgba(4, 95, 178, 1);
        color: #fff;
      }
    }
  }

  // 内容区域样式
  .content {
    .empty-tip {
      display: flex;
      flex-direction: column;
      align-items: center;
      margin-top: 100rpx;

      .empty-img {
        width: 120rpx;
        height: 120rpx;
        margin-bottom: 20rpx;
      }

      .tip-text {
        font-size: 28rpx;
        color: #999;
      }
    }
  }
}
</style>